﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebUI.Models;
using Services;

namespace WebUI.Areas.Bots.Controllers
{
    public partial class SpecificHoursController : Controller
    {
        #region Member Variables

        readonly ICSVService _csvService;

        #endregion

        #region Constructor

        public SpecificHoursController(ICSVService csvService)
        {
            this._csvService = csvService;
        }

        #endregion

        #region Action Methods

        public virtual PartialViewResult Index()
        {
            IEnumerable<string> hours = Enumerable.Range(0, 23).Select(h => h.ToString());
            return PartialView(hours);
        }

        [HttpPost]
        public virtual JsonResult Save(IEnumerable<string> hours)
        {
            var hoursString = _csvService.ConstructDelimitedString(hours);
            return Json(JsonResponseFactory.SuccessResponse(hoursString), JsonRequestBehavior.DenyGet);
        }

        #endregion
    }
}